<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@ page import="com.google.appengine.api.datastore.Entity" %>
<%@ taglib prefix="c" uri="/WEB-INF/c.tld" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
Hello, ${name}!!!<br/>

<c:if test="${!empty memoList}">
<div>
	<%
	List<Entity> memoList = (List<Entity>)request.getAttribute("memoList");
	
	for(int i=0; i < memoList.size(); i++){
	%>
	<dl>
		<dd><%=memoList.get(i).getProperty("memoContent") %></dd>
		<dd><%=memoList.get(i).getProperty("memodt") %></dd>
		<input type="button" class="del" value="del" id="<%=memoList.get(i).getProperty("key")%>" />
	</dl>
	<%
	}
	%>
</div>
</c:if>

<form name="frm" id="frm" method="post">
<input type="hidden" name="name" id="name" value="${name}"/>
<textarea name="memoContent" id="memoContent" cols="10" rows="5"></textarea><br/>
<input type="button" id="sendMemo" value="memo" />
</form>
</body>
</html>
<script type="text/javascript">
	$("#sendMemo").click(function(){
		var memoContent = $("#memoContent").val();
		if(memoContent == ''){
			alert("write memo.")
			return;
		}else{
			var name = $("#name").val();
			$("#frm").attr('action','/memo/insertMemo').submit();
		}
	});
</script>